<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="产品ID" prop="pid">
        <el-input
          v-model="queryParams.pid"
          placeholder="请输入产品ID"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
        <el-button icon="Refresh" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="Plus"
          @click="handleAdd"
          v-hasPermi="['system:transportation:add']"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="Edit"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['system:transportation:edit']"
        >修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="Delete"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['system:transportation:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="Download"
          @click="handleExport"
          v-hasPermi="['system:transportation:export']"
        >导出</el-button>
      </el-col>
      <right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="transportationList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="主键" align="center" prop="id" />
      <el-table-column label="产品ID" align="center" prop="pid" />
      <el-table-column label="类型标识" align="center" prop="ptype" />
      <el-table-column label="组装线类型" align="center" prop="assemblyLineType" />
      <el-table-column label="站名" align="center" prop="stationName1" />
      <el-table-column label="工时(小时)" align="center" prop="laborHour" />
      <el-table-column label="人力(人)" align="center" prop="laborHeadcount" />
      <el-table-column label="人工成本率/HR(元/小时)" align="center" prop="laborCostRatePerHour" />
      <el-table-column label="秒/时" align="center" prop="secondPerHour" />
      <el-table-column label="人工装配线总投资(元)" align="center" prop="manualLineTotalInvestment" />
      <el-table-column label="人工装配线耗电功率(kW)" align="center" prop="manualLinePowerConsumption" />
      <el-table-column label="人工装配效率(%)" align="center" prop="manualLineEfficiency" />
      <el-table-column label="人工装配不良费率(%)" align="center" prop="manualLineDefectRate" />
      <el-table-column label="线外工时(小时)" align="center" prop="offlineHour" />
      <el-table-column label="工站工时总和(小时)" align="center" prop="stationHourSum" />
      <el-table-column label="单站平衡工时(小时)" align="center" prop="singleStationBalanceHour" />
      <el-table-column label="最大平衡工时(小时)" align="center" prop="maxBalanceHour" />
      <el-table-column label="手动线总人力(人)" align="center" prop="manualLineTotalHeadcount" />
      <el-table-column label="手动线总工时(小时)" align="center" prop="manualLineTotalHour" />
      <el-table-column label="手动线生产成本(元)" align="center" prop="manualLineProductionCost" />
      <el-table-column label="手动线不良费用(元)" align="center" prop="manualLineDefectCost" />
      <el-table-column label="手动线装配设备成本(元)" align="center" prop="manualLineEquipmentCost" />
      <el-table-column label="手动线装配线成本率(%)" align="center" prop="manualLineCostRate" />
      <el-table-column label="手动线装配总成本(元)" align="center" prop="manualLineTotalCost" />
      <el-table-column label="手动线一天产能(KPCS)" align="center" prop="manualLineDailyCapacityKpcs" />
      <el-table-column label="自动线装配平衡工时(小时)" align="center" prop="autoLineBalanceHour" />
      <el-table-column label="自动装配人力(人)" align="center" prop="autoLineHeadcount" />
      <el-table-column label="自动线人工成本率(元/小时)" align="center" prop="autoLineLaborCostRate" />
      <el-table-column label="自动线投资(元)" align="center" prop="autoLineInvestment" />
      <el-table-column label="自动线功率(kW)" align="center" prop="autoLinePower" />
      <el-table-column label="自动线装配效率(%)" align="center" prop="autoLineEfficiency" />
      <el-table-column label="自动线不良费率(%)" align="center" prop="autoLineDefectRate" />
      <el-table-column label="自动线人力成本(元)" align="center" prop="autoLineLaborCost" />
      <el-table-column label="自动线装配成本(元)" align="center" prop="autoLineAssemblyCost" />
      <el-table-column label="自动线成本率(%)" align="center" prop="autoLineCostRate" />
      <el-table-column label="自动线不良费(元)" align="center" prop="autoLineDefectCost" />
      <el-table-column label="自动线总成本(元)" align="center" prop="autoLineTotalCost" />
      <el-table-column label="自动线一天产能(KPCS)" align="center" prop="autoLineDailyCapacityKpcs" />
      <el-table-column label="每箱包装成本(元)" align="center" prop="packCostPerCarton" />
      <el-table-column label="每箱包装量(PCS)" align="center" prop="packQtyPerCarton" />
      <el-table-column label="包材损耗(元)" align="center" prop="packMaterialLossCost" />
      <el-table-column label="包材成本(元)" align="center" prop="packMaterialTotalCost" />
      <el-table-column label="车辆费用(元/车)" align="center" prop="vehicleFee" />
      <el-table-column label="每车栈板数" align="center" prop="palletsPerVehicle" />
      <el-table-column label="每栈板箱数" align="center" prop="cartonsPerPallet" />
      <el-table-column label="每车总产品数" align="center" prop="totalProductsPerVehicle" />
      <el-table-column label="产品运输费用(元/PCS)" align="center" prop="productTransportFee" />
      <el-table-column label="装配包装运输总费用(元)" align="center" prop="assemblyPackTransportTotalFee" />
      <el-table-column label="创建日期" align="center" prop="createDate" width="180">
        <template #default="scope">
          <span>{{ parseTime(scope.row.createDate, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="删除日期" align="center" prop="deleteDate" width="180">
        <template #default="scope">
          <span>{{ parseTime(scope.row.deleteDate, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template #default="scope">
          <el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['system:transportation:edit']">修改</el-button>
          <el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['system:transportation:remove']">删除</el-button>
        </template>
      </el-table-column>
    </el-table>
    
    <pagination
      v-show="total>0"
      :total="total"
      v-model:page="queryParams.pageNum"
      v-model:limit="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改装配包装运输对话框 -->
    <el-dialog :title="title" v-model="open" width="500px" append-to-body>
      <el-form ref="transportationRef" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="产品ID" prop="pid">
          <el-input v-model="form.pid" placeholder="请输入产品ID" />
        </el-form-item>
        <el-form-item label="站名" prop="stationName1">
          <el-input v-model="form.stationName1" placeholder="请输入站名" />
        </el-form-item>
        <el-form-item label="工时(小时)" prop="laborHour">
          <el-input v-model="form.laborHour" placeholder="请输入工时(小时)" />
        </el-form-item>
        <el-form-item label="人力(人)" prop="laborHeadcount">
          <el-input v-model="form.laborHeadcount" placeholder="请输入人力(人)" />
        </el-form-item>
        <el-form-item label="人工成本率/HR(元/小时)" prop="laborCostRatePerHour">
          <el-input v-model="form.laborCostRatePerHour" placeholder="请输入人工成本率/HR(元/小时)" />
        </el-form-item>
        <el-form-item label="秒/时" prop="secondPerHour">
          <el-input v-model="form.secondPerHour" placeholder="请输入秒/时" />
        </el-form-item>
        <el-form-item label="人工装配线总投资(元)" prop="manualLineTotalInvestment">
          <el-input v-model="form.manualLineTotalInvestment" placeholder="请输入人工装配线总投资(元)" />
        </el-form-item>
        <el-form-item label="人工装配线耗电功率(kW)" prop="manualLinePowerConsumption">
          <el-input v-model="form.manualLinePowerConsumption" placeholder="请输入人工装配线耗电功率(kW)" />
        </el-form-item>
        <el-form-item label="人工装配效率(%)" prop="manualLineEfficiency">
          <el-input v-model="form.manualLineEfficiency" placeholder="请输入人工装配效率(%)" />
        </el-form-item>
        <el-form-item label="人工装配不良费率(%)" prop="manualLineDefectRate">
          <el-input v-model="form.manualLineDefectRate" placeholder="请输入人工装配不良费率(%)" />
        </el-form-item>
        <el-form-item label="线外工时(小时)" prop="offlineHour">
          <el-input v-model="form.offlineHour" placeholder="请输入线外工时(小时)" />
        </el-form-item>
        <el-form-item label="工站工时总和(小时)" prop="stationHourSum">
          <el-input v-model="form.stationHourSum" placeholder="请输入工站工时总和(小时)" />
        </el-form-item>
        <el-form-item label="单站平衡工时(小时)" prop="singleStationBalanceHour">
          <el-input v-model="form.singleStationBalanceHour" placeholder="请输入单站平衡工时(小时)" />
        </el-form-item>
        <el-form-item label="最大平衡工时(小时)" prop="maxBalanceHour">
          <el-input v-model="form.maxBalanceHour" placeholder="请输入最大平衡工时(小时)" />
        </el-form-item>
        <el-form-item label="手动线总人力(人)" prop="manualLineTotalHeadcount">
          <el-input v-model="form.manualLineTotalHeadcount" placeholder="请输入手动线总人力(人)" />
        </el-form-item>
        <el-form-item label="手动线总工时(小时)" prop="manualLineTotalHour">
          <el-input v-model="form.manualLineTotalHour" placeholder="请输入手动线总工时(小时)" />
        </el-form-item>
        <el-form-item label="手动线生产成本(元)" prop="manualLineProductionCost">
          <el-input v-model="form.manualLineProductionCost" placeholder="请输入手动线生产成本(元)" />
        </el-form-item>
        <el-form-item label="手动线不良费用(元)" prop="manualLineDefectCost">
          <el-input v-model="form.manualLineDefectCost" placeholder="请输入手动线不良费用(元)" />
        </el-form-item>
        <el-form-item label="手动线装配设备成本(元)" prop="manualLineEquipmentCost">
          <el-input v-model="form.manualLineEquipmentCost" placeholder="请输入手动线装配设备成本(元)" />
        </el-form-item>
        <el-form-item label="手动线装配线成本率(%)" prop="manualLineCostRate">
          <el-input v-model="form.manualLineCostRate" placeholder="请输入手动线装配线成本率(%)" />
        </el-form-item>
        <el-form-item label="手动线装配总成本(元)" prop="manualLineTotalCost">
          <el-input v-model="form.manualLineTotalCost" placeholder="请输入手动线装配总成本(元)" />
        </el-form-item>
        <el-form-item label="手动线一天产能(KPCS)" prop="manualLineDailyCapacityKpcs">
          <el-input v-model="form.manualLineDailyCapacityKpcs" placeholder="请输入手动线一天产能(KPCS)" />
        </el-form-item>
        <el-form-item label="自动线装配平衡工时(小时)" prop="autoLineBalanceHour">
          <el-input v-model="form.autoLineBalanceHour" placeholder="请输入自动线装配平衡工时(小时)" />
        </el-form-item>
        <el-form-item label="自动装配人力(人)" prop="autoLineHeadcount">
          <el-input v-model="form.autoLineHeadcount" placeholder="请输入自动装配人力(人)" />
        </el-form-item>
        <el-form-item label="自动线人工成本率(元/小时)" prop="autoLineLaborCostRate">
          <el-input v-model="form.autoLineLaborCostRate" placeholder="请输入自动线人工成本率(元/小时)" />
        </el-form-item>
        <el-form-item label="自动线投资(元)" prop="autoLineInvestment">
          <el-input v-model="form.autoLineInvestment" placeholder="请输入自动线投资(元)" />
        </el-form-item>
        <el-form-item label="自动线功率(kW)" prop="autoLinePower">
          <el-input v-model="form.autoLinePower" placeholder="请输入自动线功率(kW)" />
        </el-form-item>
        <el-form-item label="自动线装配效率(%)" prop="autoLineEfficiency">
          <el-input v-model="form.autoLineEfficiency" placeholder="请输入自动线装配效率(%)" />
        </el-form-item>
        <el-form-item label="自动线不良费率(%)" prop="autoLineDefectRate">
          <el-input v-model="form.autoLineDefectRate" placeholder="请输入自动线不良费率(%)" />
        </el-form-item>
        <el-form-item label="自动线人力成本(元)" prop="autoLineLaborCost">
          <el-input v-model="form.autoLineLaborCost" placeholder="请输入自动线人力成本(元)" />
        </el-form-item>
        <el-form-item label="自动线装配成本(元)" prop="autoLineAssemblyCost">
          <el-input v-model="form.autoLineAssemblyCost" placeholder="请输入自动线装配成本(元)" />
        </el-form-item>
        <el-form-item label="自动线成本率(%)" prop="autoLineCostRate">
          <el-input v-model="form.autoLineCostRate" placeholder="请输入自动线成本率(%)" />
        </el-form-item>
        <el-form-item label="自动线不良费(元)" prop="autoLineDefectCost">
          <el-input v-model="form.autoLineDefectCost" placeholder="请输入自动线不良费(元)" />
        </el-form-item>
        <el-form-item label="自动线总成本(元)" prop="autoLineTotalCost">
          <el-input v-model="form.autoLineTotalCost" placeholder="请输入自动线总成本(元)" />
        </el-form-item>
        <el-form-item label="自动线一天产能(KPCS)" prop="autoLineDailyCapacityKpcs">
          <el-input v-model="form.autoLineDailyCapacityKpcs" placeholder="请输入自动线一天产能(KPCS)" />
        </el-form-item>
        <el-form-item label="每箱包装成本(元)" prop="packCostPerCarton">
          <el-input v-model="form.packCostPerCarton" placeholder="请输入每箱包装成本(元)" />
        </el-form-item>
        <el-form-item label="每箱包装量(PCS)" prop="packQtyPerCarton">
          <el-input v-model="form.packQtyPerCarton" placeholder="请输入每箱包装量(PCS)" />
        </el-form-item>
        <el-form-item label="包材损耗(元)" prop="packMaterialLossCost">
          <el-input v-model="form.packMaterialLossCost" placeholder="请输入包材损耗(元)" />
        </el-form-item>
        <el-form-item label="包材成本(元)" prop="packMaterialTotalCost">
          <el-input v-model="form.packMaterialTotalCost" placeholder="请输入包材成本(元)" />
        </el-form-item>
        <el-form-item label="车辆费用(元/车)" prop="vehicleFee">
          <el-input v-model="form.vehicleFee" placeholder="请输入车辆费用(元/车)" />
        </el-form-item>
        <el-form-item label="每车栈板数" prop="palletsPerVehicle">
          <el-input v-model="form.palletsPerVehicle" placeholder="请输入每车栈板数" />
        </el-form-item>
        <el-form-item label="每栈板箱数" prop="cartonsPerPallet">
          <el-input v-model="form.cartonsPerPallet" placeholder="请输入每栈板箱数" />
        </el-form-item>
        <el-form-item label="每车总产品数" prop="totalProductsPerVehicle">
          <el-input v-model="form.totalProductsPerVehicle" placeholder="请输入每车总产品数" />
        </el-form-item>
        <el-form-item label="产品运输费用(元/PCS)" prop="productTransportFee">
          <el-input v-model="form.productTransportFee" placeholder="请输入产品运输费用(元/PCS)" />
        </el-form-item>
        <el-form-item label="装配包装运输总费用(元)" prop="assemblyPackTransportTotalFee">
          <el-input v-model="form.assemblyPackTransportTotalFee" placeholder="请输入装配包装运输总费用(元)" />
        </el-form-item>
        <el-form-item label="全局唯一标识" prop="uid">
          <el-input v-model="form.uid" placeholder="请输入全局唯一标识" />
        </el-form-item>
        <el-divider content-position="center">包装详情信息</el-divider>
        <el-row :gutter="10" class="mb8">
          <el-col :span="1.5">
            <el-button type="primary" icon="Plus" @click="handleAddEcdPackageDetail">添加</el-button>
          </el-col>
          <el-col :span="1.5">
            <el-button type="danger" icon="Delete" @click="handleDeleteEcdPackageDetail">删除</el-button>
          </el-col>
        </el-row>
        <el-table :data="ecdPackageDetailList" :row-class-name="rowEcdPackageDetailIndex" @selection-change="handleEcdPackageDetailSelectionChange" ref="ecdPackageDetail">
          <el-table-column type="selection" width="50" align="center" />
          <el-table-column label="序号" align="center" prop="index" width="50"/>
          <el-table-column label="包材名称" prop="packName" width="150">
            <template #default="scope">
              <el-input v-model="scope.row.packName" placeholder="请输入包材名称" />
            </template>
          </el-table-column>
          <el-table-column label="用量" prop="packQty" width="150">
            <template #default="scope">
              <el-input v-model="scope.row.packQty" placeholder="请输入用量" />
            </template>
          </el-table-column>
          <el-table-column label="损耗(%)" prop="packLoss" width="150">
            <template #default="scope">
              <el-input v-model="scope.row.packLoss" placeholder="请输入损耗(%)" />
            </template>
          </el-table-column>
          <el-table-column label="单价(元)" prop="packUnitPrice" width="150">
            <template #default="scope">
              <el-input v-model="scope.row.packUnitPrice" placeholder="请输入单价(元)" />
            </template>
          </el-table-column>
          <el-table-column label="小计(元)" prop="packSubtotal" width="150">
            <template #default="scope">
              <el-input v-model="scope.row.packSubtotal" placeholder="请输入小计(元)" />
            </template>
          </el-table-column>
          <el-table-column label="全局唯一标识" prop="uid" width="150">
            <template #default="scope">
              <el-input v-model="scope.row.uid" placeholder="请输入全局唯一标识" />
            </template>
          </el-table-column>
          <el-table-column label="更新日期" prop="updateDate" width="240">
            <template #default="scope">
              <el-date-picker clearable
                v-model="scope.row.updateDate"
                type="date"
                value-format="YYYY-MM-DD"
                placeholder="请选择更新日期">
              </el-date-picker>
            </template>
          </el-table-column>
          <el-table-column label="创建日期" prop="createDate" width="240">
            <template #default="scope">
              <el-date-picker clearable
                v-model="scope.row.createDate"
                type="date"
                value-format="YYYY-MM-DD"
                placeholder="请选择创建日期">
              </el-date-picker>
            </template>
          </el-table-column>
          <el-table-column label="删除日期" prop="deleteDate" width="240">
            <template #default="scope">
              <el-date-picker clearable
                v-model="scope.row.deleteDate"
                type="date"
                value-format="YYYY-MM-DD"
                placeholder="请选择删除日期">
              </el-date-picker>
            </template>
          </el-table-column>
        </el-table>
      </el-form>
      <template #footer>
        <div class="dialog-footer">
          <el-button type="primary" @click="submitForm">确 定</el-button>
          <el-button @click="cancel">取 消</el-button>
        </div>
      </template>
    </el-dialog>
  </div>
</template>

<script setup name="Transportation">
import { listTransportation, getTransportation, delTransportation, addTransportation, updateTransportation } from "@/api/system/transportation"

const { proxy } = getCurrentInstance()

const transportationList = ref([])
const ecdPackageDetailList = ref([])
const open = ref(false)
const loading = ref(true)
const showSearch = ref(true)
const ids = ref([])
const checkedEcdPackageDetail = ref([])
const single = ref(true)
const multiple = ref(true)
const total = ref(0)
const title = ref("")

const data = reactive({
  form: {},
  queryParams: {
    pageNum: 1,
    pageSize: 10,
    pid: null,
  },
  rules: {
    pid: [
      { required: true, message: "产品ID不能为空", trigger: "blur" }
    ],
  }
})

const { queryParams, form, rules } = toRefs(data)

/** 查询装配包装运输列表 */
function getList() {
  loading.value = true
  listTransportation(queryParams.value).then(response => {
    transportationList.value = response.rows
    total.value = response.total
    loading.value = false
  })
}

// 取消按钮
function cancel() {
  open.value = false
  reset()
}

// 表单重置
function reset() {
  form.value = {
    id: null,
    pid: null,
    ptype: null,
    assemblyLineType: null,
    stationName1: null,
    laborHour: null,
    laborHeadcount: null,
    laborCostRatePerHour: null,
    secondPerHour: null,
    manualLineTotalInvestment: null,
    manualLinePowerConsumption: null,
    manualLineEfficiency: null,
    manualLineDefectRate: null,
    offlineHour: null,
    stationHourSum: null,
    singleStationBalanceHour: null,
    maxBalanceHour: null,
    manualLineTotalHeadcount: null,
    manualLineTotalHour: null,
    manualLineProductionCost: null,
    manualLineDefectCost: null,
    manualLineEquipmentCost: null,
    manualLineCostRate: null,
    manualLineTotalCost: null,
    manualLineDailyCapacityKpcs: null,
    autoLineBalanceHour: null,
    autoLineHeadcount: null,
    autoLineLaborCostRate: null,
    autoLineInvestment: null,
    autoLinePower: null,
    autoLineEfficiency: null,
    autoLineDefectRate: null,
    autoLineLaborCost: null,
    autoLineAssemblyCost: null,
    autoLineCostRate: null,
    autoLineDefectCost: null,
    autoLineTotalCost: null,
    autoLineDailyCapacityKpcs: null,
    packCostPerCarton: null,
    packQtyPerCarton: null,
    packMaterialLossCost: null,
    packMaterialTotalCost: null,
    vehicleFee: null,
    palletsPerVehicle: null,
    cartonsPerPallet: null,
    totalProductsPerVehicle: null,
    productTransportFee: null,
    assemblyPackTransportTotalFee: null,
    uid: null,
    updateDate: null,
    createDate: null,
    deleteDate: null
  }
  ecdPackageDetailList.value = []
  proxy.resetForm("transportationRef")
}

/** 搜索按钮操作 */
function handleQuery() {
  queryParams.value.pageNum = 1
  getList()
}

/** 重置按钮操作 */
function resetQuery() {
  proxy.resetForm("queryRef")
  handleQuery()
}

// 多选框选中数据
function handleSelectionChange(selection) {
  ids.value = selection.map(item => item.id)
  single.value = selection.length != 1
  multiple.value = !selection.length
}

/** 新增按钮操作 */
function handleAdd() {
  reset()
  open.value = true
  title.value = "添加装配包装运输"
}

/** 修改按钮操作 */
function handleUpdate(row) {
  reset()
  const _id = row.id || ids.value
  getTransportation(_id).then(response => {
    form.value = response.data
    ecdPackageDetailList.value = response.data.ecdPackageDetailList
    open.value = true
    title.value = "修改装配包装运输"
  })
}

/** 提交按钮 */
function submitForm() {
  proxy.$refs["transportationRef"].validate(valid => {
    if (valid) {
      form.value.ecdPackageDetailList = ecdPackageDetailList.value
      if (form.value.id != null) {
        updateTransportation(form.value).then(response => {
          proxy.$modal.msgSuccess("修改成功")
          open.value = false
          getList()
        })
      } else {
        addTransportation(form.value).then(response => {
          proxy.$modal.msgSuccess("新增成功")
          open.value = false
          getList()
        })
      }
    }
  })
}

/** 删除按钮操作 */
function handleDelete(row) {
  const _ids = row.id || ids.value
  proxy.$modal.confirm('是否确认删除装配包装运输编号为"' + _ids + '"的数据项？').then(function() {
    return delTransportation(_ids)
  }).then(() => {
    getList()
    proxy.$modal.msgSuccess("删除成功")
  }).catch(() => {})
}

/** 包装详情序号 */
function rowEcdPackageDetailIndex({ row, rowIndex }) {
  row.index = rowIndex + 1
}

/** 包装详情添加按钮操作 */
function handleAddEcdPackageDetail() {
  let obj = {}
  obj.packName = ""
  obj.packQty = ""
  obj.packLoss = ""
  obj.packUnitPrice = ""
  obj.packSubtotal = ""
  obj.uid = ""
  obj.updateDate = ""
  obj.createDate = ""
  obj.deleteDate = ""
  ecdPackageDetailList.value.push(obj)
}

/** 包装详情删除按钮操作 */
function handleDeleteEcdPackageDetail() {
  if (checkedEcdPackageDetail.value.length == 0) {
    proxy.$modal.msgError("请先选择要删除的包装详情数据")
  } else {
    const ecdPackageDetails = ecdPackageDetailList.value
    const checkedEcdPackageDetails = checkedEcdPackageDetail.value
    ecdPackageDetailList.value = ecdPackageDetails.filter(function(item) {
      return checkedEcdPackageDetails.indexOf(item.index) == -1
    })
  }
}

/** 复选框选中数据 */
function handleEcdPackageDetailSelectionChange(selection) {
  checkedEcdPackageDetail.value = selection.map(item => item.index)
}

/** 导出按钮操作 */
function handleExport() {
  proxy.download('system/transportation/export', {
    ...queryParams.value
  }, `transportation_${new Date().getTime()}.xlsx`)
}

getList()
</script>
